package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConst;
import com.itheima.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealServic;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
@Slf4j
public class SetmealController {

	@Reference
	SetmealServic setmealServic;

	@RequestMapping("getSetmeal")
	public Result getSetmeal(){

		log.debug("SetmealController");

		List<Setmeal> setmealList  = setmealServic.getSetmeal();

		log.debug("查询成功setmealList==="+setmealList.toString());

		return new Result(true, MessageConst.QUERY_SETMEAL_SUCCESS,setmealList);

	}


	@RequestMapping("/findDetailsById")
	public Result findDetailsById(Integer id){

		log.debug("SetmealController   id=="+id);

		Setmeal setmeal = setmealServic.findDetailsById(id);

		log.debug("查询成功 setmeal=="+setmeal);


		return new Result(true,MessageConst.QUERY_SETMEAL_SUCCESS,setmeal);
	}

	@RequestMapping("/findById")
	public Result findById(Integer id){

		log.debug("SetmealController   id=="+id);

		Setmeal setmeal = setmealServic.findById(id);

		log.debug("查询成功 setmeal=="+setmeal);


		return new Result(true,MessageConst.QUERY_SETMEAL_SUCCESS,setmeal);
	}

}
